package blms.system;

import blms.system.exception.UnknownUserAttribute;

public enum UserAttributes {
	
	FIRST_NAME("firstName"), LAST_NAME("lastName"), HOME_PHONE("homePhone"),
	WORK_PHONE("workPhone"), CELL_PHONE("cellPhone"), EMAIL("email"), PICTURE("picture");

	private String type;
	
	private UserAttributes(String type) {
		this.type = type;
	}
	
	public String toString() {
		if (this.type.equals("firstName")) return "first name";
		if (this.type.equals("lastName")) return "last name";
		return this.type;
	}
	
	public static boolean isMandatory(String attribute) {
		try {
			
			UserAttributes att = UserAttributes.translateAttribute(attribute);
			
			if (att.equals(FIRST_NAME) || (att.equals(LAST_NAME)) || att.equals(EMAIL)) return true;
			return false;
		
		} catch (UnknownUserAttribute e) {
			return false;
		}
	}
	
	public static UserAttributes translateAttribute(String attribute) throws UnknownUserAttribute {
		if (attribute == null || attribute.equals("")) throw new UnknownUserAttribute();
		
		if (attribute.equals("firstName")) return FIRST_NAME;
		if (attribute.equals("lastName")) return LAST_NAME;
		if (attribute.equals("homePhone")) return HOME_PHONE;
		if (attribute.equals("workPhone")) return WORK_PHONE;
		if (attribute.equals("cellPhone")) return CELL_PHONE;
		if (attribute.equals("email")) return EMAIL;
		if (attribute.equals("picture")) return PICTURE;
		
		throw new UnknownUserAttribute();
	}
}
